import {ElLoading} from 'element-plus'

/**
 * 判断字符串不能为 空，空字符串，空格空字符串
 * @param obj
 */
export function isNotBlank(obj: any) {
    if (obj instanceof String) {
        return obj && obj !== '' && obj !== '' && obj !== null && obj !== undefined
    }
    if (obj instanceof Object) {
        return obj !== null && obj !== undefined && Object.keys(obj).length !== 0
    }
    return obj && obj !== '' && obj !== '' && obj !== null && obj !== undefined
}

export function isBlank(obj: any) {
    return !(obj && obj !== '' && obj !== '' && obj !== null && obj !== undefined)
}

/**
 * 判断数组不能为空
 * @param obj
 */
export function isNotEmpty(obj: any[]) {
    return obj && obj.length > 0
}

export function isEmpty(obj: any[]) {
    return !(obj && obj.length > 0)
}

export function listToMap(dataList: any[], fieldName: any) {
    return dataList.reduce((obj, item) => {
        obj[item[fieldName]] = item
        return obj
    }, {})
}
